// 日期区间
laydate.render({
    elem: '#between'
    ,range: true
  });
// 车辆选择
$('.number').on('click',()=>{
    opsearch('{:url("html/car/car")}?op=search')
 })
// 添加司机评价记录跳转
$('#add').on('click',()=>{
    window.location.href = "{:url('html/plus/service_add')}"
})

var page = 1;
var pagenum = 10;
var fi=1;
var url={
    list:api.driver.driverel
}
var main=[[ //表头
     {field: 'order_no', title: '订单号', fixed: 'left',minWidth:180}
    ,{field: 'name', title: '司机姓名'}
    ,{field: 'phone', title: '司机电话'}  
    ,{field: 'car_number', title: '车牌号'}
    ,{field:'evaluate_time', title:'评价时间'}
    ,{field:'star', title:'星级评分'}
]];
var data={};
data.page=page;
data.pagenum=pagenum;

var where_json ={};

{if $Think.get.name}
data.name= '{$Think.get.name}'
{/if}

{if $Think.get.phone}
data.phone= '{$Think.get.phone}'
{/if}

{if $Think.get.order_no}
data.order_no= '{$Think.get.order_no}'
{/if}
{if $Think.get.between}
        var time = '{$Think.get.between}'.split(' ');
        data.start=time[0];
        data.end=time[2];
{/if}


data.where_json=JSON.stringify(where_json)

ajaxdriver(data);
function ajaxdriver(data) {
    Load();
    //请求数据
    ajax(url.list, data, 'post').done(function (resp) {
        Load(1);
        // 成功回调
        //方法级表单渲染
        console.log(resp)
        if(resp.code == 1){
        table.render({
            elem: '#driver_el',
            cols: main,
            data: resp.data.list,
            limit: pagenum,
            cellMinWidth: 80
        });
        if (fi == 1) {
            laypage.render({
                elem: 'page',
                count: resp.data.count,
                layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'],
                theme: '#1E9FFF',
                jump: function (obj, first) {
                    console.log(obj)
                    if (!first) {
                        page = obj.curr;
                        data.page = page;
                        pagenum = obj.limit;
                        data.pagenum = pagenum;
                        ajaxdriver(data);
                    } else {

                    }
                }
            })
            fi = 2;
        }
    }else{
        Err(resp.msg)
    }
    }).fail(function (err) {
        // 失败回调
        Load(1)
        Err('请求失败')
    });
};
